package com.net.common.enums.jackson;

import java.io.IOException;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import com.net.common.enums.base.StringEnum;

/**
 * @author  on 2017/6/8.
 * StringEnum的序列化类
 */
public class StringEnumJacksonSerializer<E extends Enum<E> & StringEnum<E>> extends StdSerializer<E> {
    public StringEnumJacksonSerializer(Class<E> t) {
        super(t);
    }

    @Override
    public void serialize(E value, JsonGenerator gen, SerializerProvider provider) throws IOException {
        gen.writeString(value.getValue());
    }
}
